import router from '@/router'
import { getTOken } from './stores/token'
// 设置白名单
const white = ['/login','/404']
router.beforeEach((to, from, next) => {
    // to and from are both route objects. must call `next`.
    const token = getTOken()
    if(token){
        if(to.path === '/login'){
            next('/')
        }else{
            next()
        }

    }else{
        if(white.includes(to.path)){
            next()
        }else{
            next('/login')
        }
    }
})
